<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%String basePath = request.getContextPath(); %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加菜品</title>
<script type="text/javascript" src="<%=basePath%>/resource/js/constants.js"></script>
<script type="text/javascript" src="<%=basePath%>/resource/js/ajax_constants.js"></script>
<script type="text/javascript" src="<%=basePath%>/resource/js/jquery/jquery-1.8.2.js"></script>
<script type="text/javascript" src="<%=basePath%>/resource/js/honeycombtool.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#addStaffSubmitButton").click(submitStaff);
	});
	function submitStaff() {
		var foodName = $("#foodName").val();
		var foodPic = $("#foodPic").val();
		var actionId = $("#actionId").val();
		var stapleFood = $("#stapleFood").val();
		//if (foodName && "" != foodName && foodPic && "" != foodPic && actionId && "" != actionId && stapleFood && "" != stapleFood) {
		if (!CHECK.isEmpty(foodName) && CHECK.isPic(foodPic) && !CHECK.isEmpty(actionId) && !CHECK.isEmpty(stapleFood))	{
			$.ajax({
				url: WEBROOT+"/play/dine/admin/ajaxAddActionFood",
				type: "post",
				dataType: "json",
				data: {"foodName": foodName,
					"foodPic": foodPic,
					"actionId": actionId,
					"stapleFood": stapleFood
				},
				success: function(res) {
					if (res.result == AjaxMsgConstants.SUCCESS) {
						alert("添加菜品成功, 具体的事还没有做");
					} else {
						alert("添加菜品失败");
					}
				}
			});
		} else {
			alert("请先完善数据,并注意输入数据的格式(图片文件类型只能为‘.jpg, .png, .bmp, .jpeg, .gif’其中之一)");
		}
	}
</script>
</head>
<body>
	<div>
		菜品名:<input type="text" id="foodName" />
	</div>
	<div>
		菜品实例图:<input type="text" id="foodPic" />
		<input type="hidden" id="actionId" value="<%=request.getAttribute("actionId") %>" />
	</div>
	<div>
		是否为主食：
		<select id="stapleFood">
			<option value="NOSTAPLE">否
			<option value="ISSTAPLE">是
		</select>
		<input type="hidden" id="actionId" value="<%=request.getAttribute("actionId") %>" />
	</div>
	<div>
		<input type="button" id="addStaffSubmitButton" value="添加" />
	</div>
	<div style="clear: both;"></div>
</body>
</html>